{{>licenseInfo}}
{{#models}}{{#model}}defmodule {{moduleName}}.Model.{{classname}} do
  @moduledoc """
  {{description}}
  """

  @derive [Poison.Encoder]
  defstruct [
    {{#vars}}:"{{baseName}}"{{#hasMore}},
    {{/hasMore}}{{/vars}}
  ]

  @type t :: %__MODULE__{
    {{#vars}}:"{{baseName}}" => {{{datatype}}}{{#isNullable}} | nil{{/isNullable}}{{^isNullable}}{{^required}} | nil{{/required}}{{/isNullable}}{{#hasMore}},
    {{/hasMore}}{{/vars}}
  }
end

defimpl Poison.Decoder, for: {{moduleName}}.Model.{{classname}} do
{{#hasComplexVars}}
  import {{moduleName}}.Deserializer
  def decode(value, options) do
    value
    {{#vars}}
    {{^isPrimitiveType}}
    {{#datatype}}|> deserialize(:"{{baseName}}", {{#isListContainer}}:list, {{moduleName}}.Model.{{items.datatype}}{{/isListContainer}}{{#isMapContainer}}:map, {{moduleName}}.Model.{{items.datatype}}{{/isMapContainer}}{{#isDate}}:date, nil{{/isDate}}{{#isDateTime}}:date, nil{{/isDateTime}}{{^isDate}}{{^isDateTime}}{{^isMapContainer}}{{^isListContainer}}:struct, {{moduleName}}.Model.{{dataType}}{{/isListContainer}}{{/isMapContainer}}{{/isDateTime}}{{/isDate}}, options)
    {{/datatype}}
    {{/isPrimitiveType}}
    {{/vars}}
{{/hasComplexVars}}
{{^hasComplexVars}}
  def decode(value, _options) do
    value
{{/hasComplexVars}}
  end
end
{{/model}}{{/models}}
